package es.iberdrola.arch.ri.employees.service;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;

import org.congapps.employees.model.Employee;


public class EmployeesService {
	
	private EntityManagerFactory emf ;
	private EntityManager em;
	
	public void findEmployeeByEmpNo(int emp_no){
		
		/**DAOFactory daoFactory = DAOFactory.getDAOFactory() ;
		EmployeeDAO employeeDAO = daoFactory.getEmployeeDAO() ;
		Employee employee = employeeDAO.findEmployeeByEmpNo(emp_no) ;*/
	}
	
	public List<Employee> listEmployees(){
		
		/**DAOFactory daoFactory = DAOFactory.getDAOFactory() ;
		EmployeeDAO employeeDAO = daoFactory.getEmployeeDAO() ;
		List<Employee> employees = employeeDAO.listEmployees() ;*/
		emf = Persistence.createEntityManagerFactory("EmployeesManagement") ;
		em = emf.createEntityManager() ;
		
		//Query q = em.createNamedQuery("findAllEmployees") ;
		Query q = em.createQuery("SELECT e FROM Employee e") ;
		List<Employee> results = (List<Employee>) q.getResultList() ;
		return results ;
	}

}
